package com.youbug.mall.order_oms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.order_oms.entity.OmsOrderItem;
import com.youbug.mall.order_oms.service.IOmsOrderItemService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单项信息 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-07-09
 */
@RestController
@RequestMapping("/omsOrderItem")
public class OmsOrderItemController {
@Autowired
private IOmsOrderItemService omsOrderItemService;

    @PostMapping("/getOmsOrderItemPage")
    public R<IPage<OmsOrderItem>> getOmsOrderItemPage(@RequestBody QueryVo<OmsOrderItem> queryVo){

        IPage<OmsOrderItem> omsOrderItems = omsOrderItemService.getOmsOrderItemByOrderSns(queryVo);

        return R.ok(omsOrderItems);
    }

    @GetMapping("/getOmsOrderItemById/{id}")
    public R<OmsOrderItem> getOmsOrderItemById(@PathVariable Integer id){

        OmsOrderItem omsOrderItem = omsOrderItemService.getById(id);

        return R.ok(omsOrderItem);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody OmsOrderItem omsOrderItem){

        boolean save = omsOrderItemService.save(omsOrderItem);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody OmsOrderItem omsOrderItem){

        boolean update = omsOrderItemService.updateById(omsOrderItem);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = omsOrderItemService.removeById(id);

        return  R.ok(remove);
    }
}

